﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Fcdbas.Core.Util;
namespace FileTransferProtocol
{
    [Serializable]
    public class TFileInfo
    {
        
        [DisplayName("文件目录")]
        public string FilePath
        {
            get;
            set;
        }
        [DisplayName("文件名称")]
        public string FileName
        {
            get;
            set;
        }
        [DisplayName("文件路径")]
        public string File
        {
            get
            {
                return FilePath + "\\" + FileName;
            }
        }
        [DisplayName("文件大小")]
        public long FileSize
        {
            get;
            set;
        }
        [DisplayName("文件类型")]
        public string FileType
        {
            get;
            set;
        }
        [DisplayName("文件MD5")]
        public string MD5
        {
            get;
            set;
        }
        [DisplayName("是否完成")]
        public bool IsFinished
        {
            get;
            set;
        }
        [DisplayName("已完成")]
        /// <summary>
        /// 已完成
        /// </summary>
        public long ComplatedSize
        {
            get;
            set;
        }
        public bool IsDownLoading
        {
            get;
            set;
        }
        [DisplayName("平均速度(KB)")]
        public double KByteAverSpeed
        {
            get;
            set;
        }
        /// <summary>
        /// 已用时间
        /// </summary>
        [DisplayName("已用时间")]
        public string TimePast
        {
            get;
            set;
        }
        /// <summary>
        /// 获取估计剩余时间
        /// </summary>
        [DisplayName("剩余时间")]
        public string TimeRemaining
        {
            get;
            set;
        }
        public static TFileInfo GetFileInfo(string filePath)
        {

            TFileInfo fi = new TFileInfo();
            fi.FileName = FileHelper.GetFileNameNoPath(filePath);
            fi.FilePath = FileHelper.GetFileDir(filePath);
            fi.FileType = System.IO.Path.GetExtension(filePath).Replace('.',' ').Trim();
            fi.FileSize = FileHelper.GetFileSize(filePath);
            fi.MD5 = Fcdbas.Core.Security.DataHelper.HashFile(filePath);
            fi.IsDownLoading = false;
            fi.IsFinished = false;
            return fi;
        }
    }
}
